home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 3 / Gold Medal Software - Volume 3 (Gold Medal) (1994).iso / windows / editprog / newvisda.arj / SQL.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-03-08  |  5.2 KB  |  187 lines

  1. VERSION 2.00
  2. Begin Form fSQL 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "SQL Statement"
  5.    ClientHeight    =   3135
  6.    ClientLeft      =   3045
  7.    ClientTop       =   3390
  8.    ClientWidth     =   5250
  9.    Height          =   3540
  10.    Icon            =   SQL.FRX:0000
  11.    Left            =   2985
  12.    LinkTopic       =   "Form1"
  13.    MDIChild        =   -1  'True
  14.    ScaleHeight     =   3116.879
  15.    ScaleMode       =   0  'User
  16.    ScaleWidth      =   5268
  17.    Top             =   3045
  18.    Width           =   5370
  19.    Begin CommandButton Command1 
  20.       Caption         =   "C&opy To Clipboard"
  21.       Height          =   375
  22.       Left            =   3120
  23.       TabIndex        =   5
  24.       Top             =   600
  25.       Width           =   1695
  26.    End
  27.    Begin CheckBox cPassThru 
  28.       BackColor       =   &H00C0C0C0&
  29.       Caption         =   "&SQL PassThrough"
  30.       Height          =   225
  31.       Left            =   210
  32.       TabIndex        =   4
  33.       Top             =   553
  34.       Width           =   2640
  35.    End
  36.    Begin CommandButton CreateQueryDefbtn 
  37.       Caption         =   "Create &QueryDef"
  38.       Height          =   375
  39.       Left            =   3120
  40.       TabIndex        =   3
  41.       Top             =   120
  42.       Visible         =   0   'False
  43.       Width           =   1695
  44.    End
  45.    Begin CommandButton ExecuteSQLButton 
  46.       Caption         =   "&Execute SQL"
  47.       Default         =   -1  'True
  48.       Enabled         =   0   'False
  49.       Height          =   372
  50.       Left            =   120
  51.       TabIndex        =   2
  52.       Top             =   120
  53.       Width           =   1332
  54.    End
  55.    Begin CommandButton ClearSQLButton 
  56.       Caption         =   "&Clear SQL"
  57.       Height          =   372
  58.       Left            =   1560
  59.       TabIndex        =   1
  60.       Top             =   120
  61.       Width           =   1332
  62.    End
  63.    Begin TextBox cSQLStatement 
  64.       BackColor       =   &H00FFFFFF&
  65.       Height          =   1932
  66.       Left            =   120
  67.       MultiLine       =   -1  'True
  68.       ScrollBars      =   2  'Vertical
  69.       TabIndex        =   0
  70.       Tag             =   "OL"
  71.       Top             =   1080
  72.       Width           =   5052
  73.    End
  74. Option Explicit
  75. Sub ClearSQLButton_Click ()
  76.   cSQLStatement = ""
  77.   cSQLStatement.SetFocus
  78. End Sub
  79. Sub Command1_Click ()
  80. Clipboard.SetText cSQLStatement.Text
  81. End Sub
  82. Sub CreateQueryDefbtn_Click ()
  83.   Dim qn As String
  84.   Dim q As querydef
  85.   On Error GoTo CQDErr
  86.   qn = InputBox("Enter QueryDef Name:")
  87.   If qn = "" Then Exit Sub
  88.   Set q = gCurrentDB.CreateQueryDef(qn, cSQLStatement)
  89.   RefreshTables fTables.cTableList, True
  90.   GoTo CQDEnd
  91. CQDErr:
  92.   ShowError
  93.   Resume CQDEnd
  94. CQDEnd:
  95. End Sub
  96. Sub cSQLStatement_Change ()
  97.   If cSQLStatement <> "" Then
  98.     ExecuteSQLButton.Enabled = True
  99.   Else
  100.     ExecuteSQLButton.Enabled = False
  101.   End If
  102. End Sub
  103. Sub ExecuteSQLButton_Click ()
  104.    Dim RetSQL As Long
  105.    If cSQLStatement = "" Then Exit Sub
  106.    MsgBar "Executing SQL Statement", True
  107.    SetHourglass Me
  108.    If UCase(Mid(cSQLStatement, 1, 6)) = "SELECT" And InStr(UCase(cSQLStatement), " INTO ") = 0 Then
  109.      On Error GoTo SQLDSErr
  110. MakeDynaset:
  111.      gfFromSQL = True
  112.      'create a new dynaset form
  113.      gstDynaString = ""
  114.      On Error GoTo SQLDSErr
  115.      If VDMDI.cSingleRecord = True Then
  116.        Dim dsform1 As New fDynaset
  117.        dsform1.Show
  118.      ElseIf VDMDI.cDataCtl = True Then
  119.        Dim dsform2 As New fDataForm
  120.        dsform2.Show
  121.      Else
  122.        Dim dsform3 As New fGridFrm
  123.        dsform3.Show
  124.      End If
  125.    ElseIf UCase(cSQLStatement) = "LISTTABLES" Then
  126.      GoTo MakeDynaset
  127.    Else
  128.      On Error GoTo SQLErr
  129.      If gstDataType = "ODBC" Then
  130.        If UCase(Mid(cSQLStatement, 1, 4)) = "USE " Then
  131.          Beep
  132.          MsgBox "'Use' not allowed, try Open DataBase.", 48
  133.          GoTo SQLEnd
  134.        End If
  135.        RetSQL = gCurrentDB.ExecuteSQL(cSQLStatement)
  136.        If RetSQL > 0 Then
  137.          If gfTransPending Then gfDBChanged = True
  138.        End If
  139.        MsgBox CStr(RetSQL) + " row(s) Affected by SQL Statement.", 48
  140.      Else
  141.        gCurrentDB.Execute (cSQLStatement)
  142.        MsgBox "Execute of SQL Statement was Successful.", 48
  143.      End If
  144.    End If
  145.    GoTo SQLEnd
  146. SQLErr:
  147.    If Err = 3065 Then   'row returning so try to create dynaset
  148.      Resume MakeDynaset
  149.    End If
  150.    ShowError
  151.    Resume SQLEnd
  152. SQLDSErr:
  153.    Resume SQLEnd
  154. SQLEnd:
  155.    ResetMouse Me
  156.    MsgBar "", False
  157. End Sub
  158. Sub Form_Load ()
  159.   Dim x As Integer
  160.   cSQLStatement = GetINIString("SQLStatement", "")
  161.   x = Val(GetINIString("SQLWindowHeight", "3000"))
  162.   Height = x
  163.   x = Val(GetINIString("SQLWindowWidth", "5370"))
  164.   Width = x
  165.   x = Val(GetINIString("SQLWindowTop", "0"))
  166.   Top = x
  167.   x = Val(GetINIString("SQLWindowLeft", CStr(fTables.Left + fTables.Width)))
  168.   Left = x
  169. End Sub
  170. Sub Form_Paint ()
  171.   Outlines Me
  172. End Sub
  173. Sub Form_Resize ()
  174.   On Error Resume Next
  175.   If WindowState <> 1 Then
  176.     cSQLStatement.Width = Width - 320
  177.     cSQLStatement.Height = Height - 1450
  178.     Outlines Me
  179.     Me.Refresh
  180.   End If
  181. End Sub
  182. Sub Form_Unload (Cancel As Integer)
  183.   Dim x As Integer
  184.   Me.WindowState = 1
  185.   Cancel = True
  186. End Sub
  187.